import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.MouseMotionAdapter;
import java.io.IOException;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.ListModel;
import javax.swing.SpinnerListModel;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class HDL_Coder_Form extends javax.swing.JFrame {

	
	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	private JButton jButton_hdl_coder_ok;
	private JTextField jTextField_hdl_coder_cfu_column;
	private JLabel jLabel_hdl_coder_rows;
	private JLabel jLabel_hdl_coder_columns;
	private JTextField jTextField_hdl_coder_cfu_row;
	private JLabel jLabel_connection_list;
	private JComboBox jComboBox_connection_type;


	//Variables
	public static int hdl_coder_rows, hdl_coder_columns;
	private JTextField jTextField_hdl_coder_file_path;
	private JLabel jLabel_hdl_coder_file_path;
	public static String hdl_coder_connection_type = "";
	
	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				HDL_Coder_Form inst = new HDL_Coder_Form();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public HDL_Coder_Form() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane());
			getContentPane().setLayout(thisLayout);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.addComponentListener(new ComponentAdapter() {
			});
			{
				jButton_hdl_coder_ok = new JButton();
				jButton_hdl_coder_ok.setText("OK");
				jButton_hdl_coder_ok.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("jButton_hdl_coder_ok.actionPerformed, event="+evt);
						//TODO add your code for jButton_hdl_coder_ok.actionPerformed
						hdl_coder_columns = Integer.parseInt(jTextField_hdl_coder_cfu_column.getText());
						hdl_coder_rows = Integer.parseInt(jTextField_hdl_coder_cfu_row.getText());
						
						hdl_coder_connection_type = (String)jComboBox_connection_type.getSelectedItem(); 
						
						
						//This should be at the end
						try {
							Verilog_Main_File_Generator.main(null);
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
							System.out.println("There is some problem in creating Verilog file");
						}
						
					}
				});
			}
			{
				jLabel_hdl_coder_file_path = new JLabel();
				jLabel_hdl_coder_file_path.setText("Enter the name of the output file ");
				jLabel_hdl_coder_file_path.setToolTipText("The file name should be in '.v' format");
				jLabel_hdl_coder_file_path.addMouseMotionListener(new MouseMotionAdapter() {
				});
			}
			{
				jTextField_hdl_coder_file_path = new JTextField();
			}
			{
				jTextField_hdl_coder_cfu_row = new JTextField();
				jTextField_hdl_coder_cfu_row.setText("8");
			}
			{
				jTextField_hdl_coder_cfu_column = new JTextField();
				jTextField_hdl_coder_cfu_column.setText("8");
			}
			{
				jLabel_hdl_coder_columns = new JLabel();
				jLabel_hdl_coder_columns.setText("Enter no of columns for CFU array");
			}
			{
				jLabel_hdl_coder_rows = new JLabel();
				jLabel_hdl_coder_rows.setText("Enter no of rows for CFU array");
			}
			{
				jLabel_connection_list = new JLabel();
				jLabel_connection_list.setText("Select the type of the connection");
			}
			{
				ComboBoxModel jComboBox1Model = 
					new DefaultComboBoxModel(
							new String[] { "Cross", "Star" });
				jComboBox_connection_type = new JComboBox();
				jComboBox_connection_type.setModel(jComboBox1Model);
			}
			thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
				.addContainerGap(48, 48)
				.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(jTextField_hdl_coder_cfu_row, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(jLabel_hdl_coder_rows, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(jTextField_hdl_coder_cfu_column, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(jLabel_hdl_coder_columns, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				.addGap(31)
				.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(jTextField_hdl_coder_file_path, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(jLabel_hdl_coder_file_path, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE))
				.addGap(31)
				.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(jLabel_connection_list, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
				    .addComponent(jComboBox_connection_type, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE))
				.addGap(109)
				.addComponent(jButton_hdl_coder_ok, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				.addContainerGap(48, Short.MAX_VALUE));
			thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
				.addContainerGap(17, 17)
				.addGroup(thisLayout.createParallelGroup()
				    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				        .addComponent(jLabel_hdl_coder_file_path, GroupLayout.PREFERRED_SIZE, 241, GroupLayout.PREFERRED_SIZE)
				        .addGap(13))
				    .addGroup(thisLayout.createSequentialGroup()
				        .addPreferredGap(jLabel_hdl_coder_file_path, jLabel_hdl_coder_columns, LayoutStyle.ComponentPlacement.INDENT)
				        .addGroup(thisLayout.createParallelGroup()
				            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				                .addComponent(jLabel_hdl_coder_columns, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addGap(49))
				            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				                .addComponent(jLabel_hdl_coder_rows, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addGap(68))
				            .addGroup(thisLayout.createSequentialGroup()
				                .addPreferredGap(jLabel_hdl_coder_columns, jLabel_connection_list, LayoutStyle.ComponentPlacement.INDENT)
				                .addGroup(thisLayout.createParallelGroup()
				                    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				                        .addComponent(jLabel_connection_list, GroupLayout.PREFERRED_SIZE, 210, GroupLayout.PREFERRED_SIZE)
				                        .addGap(24))
				                    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				                        .addGap(164)
				                        .addComponent(jButton_hdl_coder_ok, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)))))))
				.addGap(32)
				.addGroup(thisLayout.createParallelGroup()
				    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				        .addComponent(jComboBox_connection_type, GroupLayout.PREFERRED_SIZE, 76, GroupLayout.PREFERRED_SIZE)
				        .addGap(0, 42, Short.MAX_VALUE))
				    .addGroup(thisLayout.createSequentialGroup()
				        .addComponent(jTextField_hdl_coder_file_path, GroupLayout.PREFERRED_SIZE, 118, GroupLayout.PREFERRED_SIZE)
				        .addGap(0, 0, Short.MAX_VALUE))
				    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				        .addComponent(jTextField_hdl_coder_cfu_column, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
				        .addGap(0, 74, Short.MAX_VALUE))
				    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				        .addComponent(jTextField_hdl_coder_cfu_row, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
				        .addGap(0, 74, Short.MAX_VALUE)))
				.addContainerGap(92, 92));
			pack();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
